version: '{build}'
image: Visual Studio 2019
configuration:
- Release
platform: x64
build:
  project: source-code/PD-Loader.sln
  verbosity: minimal
after_build:
- cmd: >-
    md %TMP%\full\

    md %TMP%\full\patches\

    md %TMP%\full\plugins\
    
    md %TMP%\full\plugins\pv_equip\

    md %TMP%\full\ram\

    md %TMP%\full\ram\databank\

    md %TMP%\update\

    md %TMP%\update\patches\
    
    md %TMP%\update\plugins\
    
    md %TMP%\update\plugins\pv_equip\
    
    md %TMP%\amd-pack\
    
    md %TMP%\amd-pack\plugins\
    
    md %TMP%\amd-pack\amd-tools\
    
    md "%TMP%\amd-pack\amd-tools\ARB Patcher Source"
    
    md "%TMP%\amd-pack\amd-tools\ARB Patcher Source\gamesettings"



    copy %APPVEYOR_BUILD_FOLDER%\source-code\x64\%CONFIGURATION%\dinput8.dll %TMP%\update\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\x64\%CONFIGURATION%\*.dva %TMP%\update\plugins\
    
    del %TMP%\update\plugins\Novidia.dva
    
    copy "%APPVEYOR_BUILD_FOLDER%\source-code\data\README - PD Loader.url" %TMP%\update\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_base_game.sfv %TMP%\update\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_base_game.md5 %TMP%\update\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_mount_data.sfv %TMP%\update\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_mount_data.md5 %TMP%\update\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\plugins\ShaderPatch.ini %TMP%\update\plugins\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\patches\custom_freeplay_text_example.p %TMP%\update\patches\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\x64\%CONFIGURATION%\dinput8.dll %TMP%\full\
    
    copy %APPVEYOR_BUILD_FOLDER%\source-code\x64\%CONFIGURATION%\*.dva %TMP%\full\plugins\
    
    del %TMP%\full\plugins\Novidia.dva

    copy "%APPVEYOR_BUILD_FOLDER%\source-code\data\README - PD Loader.url" %TMP%\full\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_base_game.sfv %TMP%\full\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_base_game.md5 %TMP%\full\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_mount_data.sfv %TMP%\full\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\verify_mount_data.md5 %TMP%\full\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\glut32.dll %TMP%\full\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\plugins\*.* %TMP%\full\plugins\
    
    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\plugins\pv_equip\*.* %TMP%\full\plugins\pv_equip\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\ram\databank\*.dat %TMP%\full\ram\databank\

    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\patches\custom_freeplay_text_example.p %TMP%\full\patches\
    
    copy %APPVEYOR_BUILD_FOLDER%\source-code\x64\%CONFIGURATION%\Novidia.dva %TMP%\amd-pack\plugins\
    
    copy %APPVEYOR_BUILD_FOLDER%\source-code\data\amd-tools\*.*  %TMP%\amd-pack\amd-tools\
    
    copy "%APPVEYOR_BUILD_FOLDER%\source-code\data\amd-tools\ARB Patcher Source\*.*"  "%TMP%\amd-pack\amd-tools\ARB Patcher Source\"
    
    copy "%APPVEYOR_BUILD_FOLDER%\source-code\data\amd-tools\ARB Patcher Source\gamesettings\*.*"  "%TMP%\amd-pack\amd-tools\ARB Patcher Source\gamesettings\"

    

    cd %TMP%\full\

    echo del dnsapi.dll > "DELETE DNSAPI.DLL.bat"

    7z a %APPVEYOR_BUILD_FOLDER%\PD-Loader-%CONFIGURATION%-AppVeyor.zip *
    
    ren dinput8.dll dnsapi.dll
    
    del "DELETE DNSAPI.DLL.bat"
    
    7z a %APPVEYOR_BUILD_FOLDER%\PD-Loader-%CONFIGURATION%-AppVeyor-Vista7.zip *

    cd %TMP%\update\

    echo del dnsapi.dll > "DELETE DNSAPI.DLL.bat"

    7z a %APPVEYOR_BUILD_FOLDER%\PD-Loader-%CONFIGURATION%-Update-AppVeyor.zip *
    
    ren dinput8.dll dnsapi.dll
    
    del "DELETE DNSAPI.DLL.bat"
    
    7z a %APPVEYOR_BUILD_FOLDER%\PD-Loader-%CONFIGURATION%-Update-AppVeyor-Vista7.zip *
    
    cd %TMP%\amd-pack\amd-tools\
    
    C:\Python38\python.exe -m pip install cx_freeze
    
    C:\Python38\Scripts\cxfreeze.exe "ARB Patcher Source\main.py" --target-dir "ARB Patcher"
    
    mkdir "ARB Patcher\gamesettings"
    
    copy "ARB Patcher Source\gamesettings\*.*" "ARB Patcher\gamesettings\"
    
    del /Q "ARB Patcher Source\gamesettings"
    
    rmdir "ARB Patcher Source\gamesettings"
    
    del /Q "ARB Patcher Source"
    
    rmdir "ARB Patcher Source"
    
    del "patch shaders py.bat"
    
    cd ..
    
    move amd-tools\README.txt AMD-README.txt
    
    7z a %APPVEYOR_BUILD_FOLDER%\PD-Loader-%CONFIGURATION%-AMDPack-AppVeyor.zip *


artifacts:
- path: PD-Loader-*.zip
